﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using DAL;
using DBUlitity;
using System.Data;

namespace BLL
{
    public class PersonBLL
    {
        public static string initRoleInfo(string customername)
        {
            string jsonStr = "[]";
            List<RoleInfo> customerList = PersonDAL.initRoleInfo(customername);
            jsonStr = JSONTools.ScriptSerialize<List<RoleInfo>>(customerList);
            return jsonStr;
        }

        public static string addPersonInfo(string UserNo,string UserName, string Password,string Tel,string CustomerName,string RoleName)
        {
            string jsonStr = PersonDAL.addPersonInfo(UserNo, UserName,  Password, Tel, CustomerName, RoleName);
            return jsonStr;
        }

        /// <summary>
        /// 保存编辑 用户
        /// </summary>
        /// <param name="UserNo"></param>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        /// <param name="Tel"></param>
        /// <param name="CustomerName"></param>
        /// <param name="RoleName"></param>
        /// <returns></returns>
        public static string editPersonInfo(string UserNo, string UserName, string Password, string Tel, string CustomerName, string RoleName)
        {
            string jsonStr = PersonDAL.editPersonInfo(UserNo, UserName, Password, Tel, CustomerName, RoleName);
            return jsonStr;
        }

        public static DataTable getPersonInfo(string sidx, string sord, string keyvalue, string CustomerName)
        {
            DataTable dt = new DataTable();
            dt = PersonDAL.getPersonInfo(sidx, sord, keyvalue, CustomerName);
            return dt;
        }

        public static string deletePersonInfo(string UserID)
        {
            int t = PersonDAL.deletePersonInfo(UserID);
            string jsonStr = string.Empty;
            if(t>0){
                jsonStr = "success";
            }
            else
            {
                jsonStr = "flaut";
            }
            return jsonStr;
        }

        public static string initeditperson(string PersonID)
        {
            string jsonStr = "[]";
            List<UserEditInfo> customerList = PersonDAL.initeditperson(PersonID);
            jsonStr = JSONTools.ScriptSerialize<List<UserEditInfo>>(customerList);
            return jsonStr;
        }
    }
}
